﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Core;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.IO;

namespace Yuanlin.Business
{
    public class ContentHtmlDetail : YuanlinUserControl,
        IReplyConverter<ContentHtmlReply, GetOperation>
    {
        protected Repeater list;
        private ContentHtml contentHtml;

        public override void GetRequests(List<BaseRequestBinder> requestBinders)
        {
            if (!Page.IsPostBack)
            {
                requestBinders.Add(RequestHelper.BuildGetContentHtmlRequest(this));
            }
        }

        private void Bind()
        {
            EntityList entities = new EntityList()  ;
            if(contentHtml != null)
            {
                entities.Add(contentHtml);
            }
            list.DataSource = entities;
            list.DataBind();
        }

        #region IReplyConverter<ContentHtmlReply,GetOperation> Members

        public void ConvertReply(ContentHtmlReply reply, GetOperation operation)
        {
            if (reply != null)
            {
                contentHtml = reply.Entity as ContentHtml;

                if (!Page.IsPostBack)
                {
                    Bind();
                }
            }
        }

        #endregion
    }
}